<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .container {
            width: 400px;
            height: 400px;
            background-color: pink;
        }
        .sub {
            width: 200px;
            /* height 对于行内元素无效 */
            height: 200px;
            background-color: orange;
            display: block;
            /* margin 的左右设置为 auto 只对块元素有效，行内元素和行内块元素都无效 */
            margin: 0 auto;
        }
    </style>
</head>
<body>
    <div class="container">
        <div class="sub">xxx</div>
    </div>
</body>
</html>